package com.wmd102.opengldemo;

import android.content.Context;
import android.graphics.PixelFormat;
import android.opengl.GLSurfaceView;
import android.util.AttributeSet;

public class DMGLSurfaceView extends GLSurfaceView {

    public static final int IMAGE_FORMAT_RGBA = 0x01;
    public static final int IMAGE_FORMAT_NV21 = 0x02;
    public static final int IMAGE_FORMAT_NV12 = 0x03;
    public static final int IMAGE_FORMAT_I420 = 0x04;

    private DMGLRender mDMGLRender;
    private NativeInterface mNativeInterface;
    public DMGLSurfaceView(Context context) {
        this(context, null);
    }

    public DMGLSurfaceView(Context context, AttributeSet attrs) {
        super(context, attrs);
        init();
    }

    public void init() {
        this.setEGLContextClientVersion(3);
        mNativeInterface = NativeInterface.getInstance();
        mDMGLRender = new DMGLRender(mNativeInterface);

        setEGLConfigChooser(8, 8, 8, 8, 16, 0);
        setRenderer(mDMGLRender);
        setRenderMode(RENDERMODE_WHEN_DIRTY);
        getHolder().setFormat(PixelFormat.TRANSLUCENT);
        setZOrderOnTop(true);
    }
}

